import random
import pygame


from Actor.Shoot_soldier import ShootSoldier


class JapaneseFireSoldier(ShootSoldier):
    def __init__(self, x, y):
        soldier_id = random.randint(1, 4)
        work_path = "../Resources/images/japanese/soldier{0}.png".format(soldier_id)
        shoot_action = "../Resources/images/japanese/soldier{0}-1.png".format(soldier_id)
        super(JapaneseFireSoldier, self).__init__(work_path, shoot_action, x, y, "小日本" + str(soldier_id), 100)
        self.count = 5
        self.key = pygame.K_DOWN

    def run(self):
        if self.count == 0:
            key = random.randint(0, 7)
            self.count = 9
            if key == 0:
                self.key = pygame.K_DOWN
            elif key == 1:
                self.key = pygame.K_UP
            elif key == 2:
                self.key = pygame.K_LEFT
            elif key == 3:
                self.key = pygame.K_RIGHT
            elif key == 4:
                self.key = pygame.K_w
            elif key == 5:
                self.key = pygame.K_s
            elif key == 6:
                self.key = pygame.K_a
            elif key == 7:
                self.key = pygame.K_d
        else:
            self.count -= 1

        super(JapaneseFireSoldier, self).run(self.key)